Repository navigation
fix(elixir_bytecode): fail the build on warnings with --warnings-as-errors - #4
Open
TrapsterDK wants to merge 1 commit into
Open
TrapsterDK wants to merge 1 commit into
TrapsterDK wants to merge 1 commit into
Conversation
…rrors
In released Elixir (checked with 1.19.5 and 1.20.4), elixirc accepts
--warnings-as-errors but exits 0 when there are warnings.
Kernel.CLI passes the option to Kernel.ParallelCompiler, which no
longer reads it. Elixir fixed this on main in de015a25d4 ("Fail
elixirc on warnings with --warnings-as-errors"), which is not in a
release yet.
When --warnings-as-errors is in elixirc_opts, capture elixirc's
stderr, print it again, and fail if elixirc exited 0 but printed a
warning, with the same message that Mix and fixed elixirc use. The
launcher's warning about a latin1 file name encoding is not a compiler
warning and does not count. When elixirc already fails, its own status
and output are kept, so with a fixed Elixir the check does nothing.
Also drop "set -x". It wrote a trace to stderr for every action, which
Bazel printed even when the build succeeded.
Tests: test/warnings has sources with an unused variable, a call to an
undefined function and an IO.warn at compile time, each compiled with
--warnings-as-errors. CI checks that each fails with the message. The
unused variable source without the option still builds in //....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In released Elixir,
elixirc --warnings-as-errorsexits 0 when there are warnings.Kernel.CLIpasses the option toKernel.ParallelCompiler, which no longer reads it. This was checked with 1.20.4 and 1.19.5.test/BUILD.bazelalready passes--warnings-as-errorsto thebasicapp, but nothing checks that it fails, so this went unnoticed.Elixir fixed it on main in de015a25d4 ("Fail elixirc on warnings with --warnings-as-errors"). That commit is not in a release yet.
Change
--warnings-as-errorsis inelixirc_opts, the ELIXIRC action captures stderr, prints it again, and fails if elixirc exited 0 but printed awarning:line. It printsCompilation failed due to warnings while using the --warnings-as-errors option, the same message as Mix and the fixed elixirc.+fnu) is not a compiler warning and does not count. Without this exclusion, thebasicapp intest/fails under--incompatible_strict_action_env.bin/elixircis still used. It execselixir +elixirc.set -xis removed. It wrote a trace of the elixirc command to stderr for every action, and Bazel printed it even when the build succeeded.Test
test/warnings: threeelixir_bytecodetargets with--warnings-as-errors, taggedmanual. They cover an unused variable, a call to an undefined function (reported after the module compiles), andIO.warnat compile time (printed without indentation).if, because! cmddoes not stop abash -estep. (The existing! bazelisk testlines have the same issue: only the last one decides the step's status.)//warnings:allowedcompiles the unused-variable source without the option and builds as part of//....main, all three targets build successfully.Test output (OTP 29.0, Elixir 1.20.3, Bazel 9.2.0,
--nohome_rc)bazel test //...intest/: Executed 1 out of 4 tests: 4 tests pass. The CI negative checks (failing_test,broken_test,empty_test) fail as expected. Each of//warnings:unused,//warnings:undefand//warnings:io_warnfails once with the message. The OTP 28.5 / Elixir 1.19.5 pair was not run as a whole.Assisted by Claude.